package think.in.spring.bean.builder;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import think.in.spring.bean.factory.UserFactory;
import think.in.spring.bean.factory.impl.UserFactoryImpl;

public class BeanDestroyDemo {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BeanDestroyDemo.class);
        UserFactory bean = context.getBean(UserFactory.class);
        System.out.println(bean.toString());
        context.close();
    }

    @Bean(destroyMethod = "destroyMethodByAnnotation")
    public UserFactory userFactory() {
        UserFactoryImpl userFactory = new UserFactoryImpl();
        return userFactory;
    }
}
